package com.starsea.book.ui.newpage.pop

import android.content.Context
import android.widget.ImageView
import android.widget.TextView
import com.lxj.xpopup.core.CenterPopupView
import com.starsea.book.R
import com.starsea.book.ui.newpage.normalview.RadiusLinearLayout
import com.starsea.book.utils.gone

/**
 * @author Lee
 * @createTime 2023-08-04 16 GMT+8
 */
class NewVersionPop(
    var mContext: Context,
    var eventContent: String = "",
    var eventUrl: String = "",
    var onResult: ((type: Int, eventUrl: String) -> Unit)? = null
) :
    CenterPopupView(mContext) {

    lateinit var iv_image: ImageView
    lateinit var tv_content: TextView
    lateinit var tv_title: TextView
    lateinit var tv_cancle: TextView
    lateinit var tv_confim: TextView
    lateinit var rll_confim: RadiusLinearLayout
    lateinit var rll_cancle: RadiusLinearLayout


    override fun getImplLayoutId(): Int {
        return R.layout.layout_activity_pop
    }

    override fun onCreate() {
        super.onCreate()

        tv_cancle = findViewById(R.id.tv_cancle)
        tv_content = findViewById(R.id.tv_content)
        tv_title = findViewById(R.id.tv_title)
        iv_image = findViewById(R.id.iv_image)
        tv_confim = findViewById(R.id.tv_confim)

        rll_cancle = findViewById(R.id.rll_cancle)
        rll_confim = findViewById(R.id.rll_confim)


        iv_image.gone()

        tv_title.text = "版本更新"
        tv_cancle.text = "不更新"
        tv_confim.text = "去更新"

        tv_content.text = eventContent


        rll_cancle.setOnClickListener {
            onResult!!.invoke(0, eventUrl)
            dismiss()
        }
        rll_confim.setOnClickListener {
            onResult!!.invoke(1, eventUrl)
            dismiss()
        }

    }


}